#ifndef DETECTOR_H
#define DETECTOR_H
#include<opencv2/opencv.hpp>
#include"Light.h"
#include"hnurm_dart/util.h"
#include"hnurm_interfaces/msg/target_state.hpp"
#include<vector>
using namespace cv;

class Detector{
    public:
        //目标引导灯
        std::vector<Light> lights;
    public:
        Scalar taregt_color_hsv_max=Scalar(75,255,255);;
        Scalar taregt_color_hsv_min=Scalar(45,(int)(255*0.46),(int)(255*0.66));
        std::vector<std::vector<Point> > contours;
        cv::Point2d img_center_pos={0,0};
        cv::Mat bin_img;
        cv::Point2d ver[4];
        cv::Point2d offset={0.0,0.0};
        float_t yaw=0.0f;
        uint8_t is_find=hnurm_interfaces::msg::TargetState::LOST_TARGET;

    public:
        Detector()=default;
        ~Detector()=default;

        //预处理
        Mat PreTreat(const Mat& img);
        //颜色识别
        Mat Color_Recognition(const Mat& img);
        //轮廓处理
        void Contours_Process(const Mat& img);
        //引导灯识别
        void detect(const Mat& frame);
        //引导灯过滤
        void Light_Filter();
        //计算中心偏移
        void Calculate_Center_Offset(const cv::Point2d& target);

        void Find_Fail();
        //绘制矩形框
        void Draw(Mat& frame);

        void Data_Process();

};

#endif